import axios from "axios";

let instance = axios.create({
  baseURL: "http://327d8337.r7.cpolar.top/",
  timeout: 5000,
});

instance.interceptors.request.use(
  (config) => {
    return config;
  },
  (err) => {
    return Promise.reject(err);
  }
);

instance.interceptors.response.use(
  (response) => {
    const { code, data, msg } = response.data;
    if (code === 200) {
      return data;
    } else {
      return Promise.reject(response.data);
    }
  },
  (err) => {
    return Promise.reject(err);
  }
);

export default instance;
